package com.hy.controller;

import com.hy.common.Result;
import com.hy.entity.TeacherLike;
import com.hy.service.TeacherLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/teacherLikes")
public class TeacherLikeController {

    @Autowired
    private TeacherLikeService teacherLikeService;

    /**
     * 添加点赞
     */
    @PostMapping
    public Result<Boolean> addLike(@RequestBody TeacherLike teacherLike) {
        return Result.success(teacherLikeService.addLike(teacherLike));
    }

    /**
     * 取消点赞
     */
    @PutMapping("/cancel/{id}")
    public Result<Boolean> cancelLike(@PathVariable Integer id) {
        return Result.success(teacherLikeService.cancelLike(id));
    }

    /**
     * 检查是否已点赞
     */
    @GetMapping("/check")
    public Result<Boolean> isLiked(@RequestParam Integer userId, @RequestParam Integer teacherId) {
        return Result.success(teacherLikeService.isLiked(userId, teacherId));
    }

    /**
     * 获取老师的点赞数
     */
    @GetMapping("/count/{teacherId}")
    public Result<Long> getTeacherLikeCount(@PathVariable Long teacherId) {
        return Result.success(teacherLikeService.getTeacherLikeCount(teacherId));
    }
} 